<?php  
class slideshow_options_ControllerModuleSlideshow extends ControllerModuleSlideshow {

	// override method
	protected function index($setting) {
		$this->data['effect'] = (empty($setting['effect']) ? 'random' : $setting['effect']);
		$this->data['animspeed'] = (empty($setting['animspeed']) ? '' : $setting['animspeed']);
		$this->data['pausetime'] = (empty($setting['pausetime']) ? '' : $setting['pausetime']);
		parent::index($setting);
	}


	// override method
	protected function preRender( $templateBuffer ) {
		if (!empty($this->data['effect'])) {
			$i = strpos( $templateBuffer, '.nivoSlider()', 0 );
			if ($i===FALSE) {
				$i = strpos( $templateBuffer, '.nivoSlider({', 0 );
				if ($i===FALSE) {
					trigger_error( "slideshow_effect_ControllerModuleSlideshow: Unable to modify '".$this->template."'" );
					exit;
				}
				$templateBuffer = str_replace( ".nivoSlider({", ".nivoSlider({effect:'<?php echo \$effect; ?>',", $templateBuffer );
			} else {
				$templateBuffer = str_replace( ".nivoSlider()", ".nivoSlider({effect:'<?php echo \$effect; ?>'})", $templateBuffer );
			}
		}

		if (!empty($this->data['animspeed'])) {
			$i = strpos( $templateBuffer, '.nivoSlider()', 0 );
			if ($i===FALSE) {
				$i = strpos( $templateBuffer, '.nivoSlider({', 0 );
				if ($i===FALSE) {
					trigger_error( "slideshow_animspeed_ControllerModuleSlideshow: Unable to modify '".$this->template."'" );
					exit;
				}
				$templateBuffer = str_replace( ".nivoSlider({", ".nivoSlider({animSpeed:'<?php echo \$animspeed; ?>',", $templateBuffer );
			} else {
				$templateBuffer = str_replace( ".nivoSlider()", ".nivoSlider({animSpeed:'<?php echo \$animspeed; ?>'})", $templateBuffer );
			}
		}

		if (!empty($this->data['pausetime'])) {
			$i = strpos( $templateBuffer, '.nivoSlider()', 0 );
			if ($i===FALSE) {
				$i = strpos( $templateBuffer, '.nivoSlider({', 0 );
				if ($i===FALSE) {
					trigger_error( "slideshow_pausetime_ControllerModuleSlideshow: Unable to modify '".$this->template."'" );
					exit;
				}
				$templateBuffer = str_replace( ".nivoSlider({", ".nivoSlider({pauseTime:'<?php echo \$pausetime; ?>',", $templateBuffer );
			} else {
				$templateBuffer = str_replace( ".nivoSlider()", ".nivoSlider({pauseTime:'<?php echo \$pausetime; ?>'})", $templateBuffer );
			}
		}


		return parent::preRender( $templateBuffer );
	}
}
?>